#include "staffwin.h"
#include "ui_staffwin.h"

StaffWin::StaffWin(QWidget *parent, int user, QString fio2) :
    QWidget(parent),
    uim(new Ui::StaffWin)
{
    uim->setupUi(this);
    this->staffmod = new StaffModel();
    this->staffmod->user_id = user;
    this->fio = fio2;
    QSqlQuery sql = QSqlQuery();
    sql.prepare("select d.dep_name from stuff s join departamets d on (d.id_departament = s.id_department) where s.id_stuff = ?");
    sql.addBindValue(user);
    sql.exec();
    if ( sql.isActive() ) {

        while ( sql.next() ) {
            this->dep = sql.value(0).toString();
        }
    }
    sql.prepare("select s.id_department from stuff s  where s.id_stuff = ?");
    sql.addBindValue(user);
    sql.exec();
    if ( sql.isActive() ) {

        while ( sql.next() ) {
            this->staffmod->department = sql.value(0).toInt();
        }
    }
    //this->staffmod->department = 1;
    uim->tableView->setModel(this->staffmod);
    this->staffmod->refresh();
}
StaffWin::~StaffWin()
{
    delete uim;
}

void StaffWin::update_win()
{
 this->staffmod->user_id = this->user_id;
     this->staffmod->refresh();
  return;
}

void StaffWin::on_bossBtn_clicked()
{
return;
}

void StaffWin::on_MesBtn_clicked()
{
return;
}

void StaffWin::on_returnBtn_clicked()
{
this->hide();
return;
}
